package com.example.service;

import com.example.entity.Pharmacy;
import com.example.mapper.PharmacyMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 张比特
 * @Data: 2024/8/27 下午3:57
 * @Version: v1.0.0
 * @Description: TODO
 **/
@Service
public class PharmacyService {

    @Resource
    private PharmacyMapper pharmacyMapper;

    /**
     * 新增
     */
    public void add(Pharmacy Pharmacy) {
        pharmacyMapper.insert(Pharmacy);
    }

    /**
     * 删除
     */
    public void deleteById(Integer id) {
        pharmacyMapper.deleteById(id);
    }

    /**
     * 修改
     */
    public void updateById(Pharmacy Pharmacy) {
        pharmacyMapper.updateById(Pharmacy);
    }

    /**
     * 根据ID查询
     */
    public Pharmacy selectById(Integer id) {
        return pharmacyMapper.selectById(id);
    }

    /**
     * 查询所有
     */
    public List<Pharmacy> selectAll(Pharmacy Pharmacy) {
        return pharmacyMapper.selectAll(Pharmacy);
    }

    /**
     * 分页查询
     */
    public PageInfo<Pharmacy> selectPage(Pharmacy Pharmacy, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Pharmacy> list = pharmacyMapper.selectAll(Pharmacy);
        return PageInfo.of(list);
    }
}
